API Documentation
Public Member Functions | Public Attributes | List of all members
nkDebug::TestClass Class Reference

The test enabling class, allowing registration within the UnitTester. More...

Inheritance diagram for nkDebug::TestClass:
nkDebug::RegisteredTestClass< T, T_NAME >

Public Member Functions

 TestClass ()
 
 TestClass (const nkLog::StringView &name)
 
virtual ~TestClass ()
 
void execute (const TestRunParameters &parameters) const
 
bool setClassInitFunction (const std::function< bool()> &func)
 
bool setClassShutdownFunction (const std::function< void()> &func)
 
bool setTestFunctionInitFunction (const std::function< bool()> &func)
 
bool setTestFunctionShutdownFunction (const std::function< void()> &func)
 

Public Attributes

FunctionSet _testFunctions
 Registered functions to run.
 
ClassInitFunctionDescriptor * _classInitFunction
 Callback called before calling the test functions.
 
ClassShutdownFunctionDescriptor * _classShutdownFunction
 Callback called after all test functions have been called.
 
ClassInitFunctionDescriptor * _testFunctionInitFunction
 Callback called before calling each function.
 
ClassShutdownFunctionDescriptor * _testFunctionShutdownFunction
 Callback called after calling each function.
 
const char * _name
 Class name for tracking purposes.
 

Detailed Description

The test enabling class, allowing registration within the UnitTester.

Implementing this class enables registering within the UnitTester for a run sequence. Utilities are provided within the class to ease the process.

An example of usage would be :

NK_TEST_CLASS("MyTestClass")
{
  NK_TEST_CLASS_INIT
  {
    // Code before the whole class is ran
  }

  NK_TEST_CLASS_SHUTDOWN
  {
    // Code after the whole class is ran
  }

  NK_TEST_FUNCTION_INIT
  {
    // Code before each function
  }

  NK_TEST_FUNCTION_SHUTDOWN
  {
    // Code after each function
  }

  NK_TEST_FUNCTION(myFirstFunction)
  {
    // First test function
  }

  NK_TEST_FUNCTION(mySecondFunction)
  {
    // Second test function
  }
}

Constructor & Destructor Documentation

◆ TestClass() [1/2]

nkDebug::TestClass::TestClass ( )

Default constructor.

◆ TestClass() [2/2]

nkDebug::TestClass::TestClass ( const nkLog::StringView name)

Named constructor.

Parameters
nameThe name to attach to the class.

◆ ~TestClass()

virtual nkDebug::TestClass::~TestClass ( )
virtual

Destructor.

Member Function Documentation

◆ execute()

void nkDebug::TestClass::execute ( const TestRunParameters parameters) const

Requests the class to run all of its registered functions.

Parameters
parametersThe run parameters.

◆ setClassInitFunction()

bool nkDebug::TestClass::setClassInitFunction ( const std::function< bool()> &  func)

Sets the callback called before the class runs all of its functions in a run.

Parameters
funcThe function to call.
Returns
A registration witness.

◆ setClassShutdownFunction()

bool nkDebug::TestClass::setClassShutdownFunction ( const std::function< void()> &  func)

Sets the callback called after all functions from the class have been run.

Parameters
funcThe function to call.
Returns
A registration witness.

◆ setTestFunctionInitFunction()

bool nkDebug::TestClass::setTestFunctionInitFunction ( const std::function< bool()> &  func)

Sets the callback called before each function run.

Parameters
funcThe function to call.
Returns
A registration witness.

◆ setTestFunctionShutdownFunction()

bool nkDebug::TestClass::setTestFunctionShutdownFunction ( const std::function< void()> &  func)

Sets the callback called after each function run.

Parameters
funcThe function to call.
Returns
A registration witness.

The documentation for this class was generated from the following file: